package com.reesechou.util;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.Reader;

/**
 * Created by jingqing.zhou on 2015/5/6.
 */
public class SqlSessionUtil {
    public static SqlSessionFactory getSqlSession()  {
        String resource = "org/mybatis/example/Configuration.xml";
        Reader reader = null;
        try {
            reader = Resources.getResourceAsReader(resource);
            return new SqlSessionFactoryBuilder().build(reader);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
